<?php
			
    include_once(CMS_HOME_DIR . "/lib/CmsContentMetadata.php");
    
    //echo $cmsDocument->countQuery();
//	echo $cmsDocument->documentIteratorQuery();
        
	$cmsDocument->resetIterator();
	
	
	
	
?>
			<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentListTable">
			  <tr>
                        	<td width="12%" class="tableHead">
                           <a href="/cms/html/index.php?sorts=datemodified&direction=<?= ($direction == "DESC") ? "ASC" : "DESC" ?>" class="greyStyle">Modified</a></td> 
                            <td  colspan="1" class="tableHead">
                            <a href="/cms/html/index.php?sorts=listlabel&direction=<?= ($direction == "DESC") ? "ASC" : "DESC" ?>" class="greyStyle"> Title</a></td>
                            <td colspan="1" class="tableHead">Class Type</td>
                          <td width="15%" class="tableHead">
                            Added                          </td>
                          <td width="18%" align="right" class="tableHead">
                            Action                          </td>
                      </tr>

<?php

	
	//$cmscontentmetadataTableWriter = new CmsTableWriter('cmscontentmetadata', $db);
	while(($row = $cmsDocument->nextDocument())){
		//$resultSet = $cmscontentmetadataTableWriter->readItem( )
		
		$cmscontentmetadata	= getCmsContentMetadataWithDocumentCode($row->documentcode, $db);
	
		//myPrintR($cmscontentmetadata);
		if ( $cmscontentmetadata && !is_null($cmscontentmetadata->listlabel) && strlen($cmscontentmetadata->listlabel) > 0  ){
			$title = $cmscontentmetadata->listlabel;
		} else {
			$title = magicClean($row->title);
		}
?>
				
			  
			  <tr class="tableContent"> 
				<td width="12%" align="center" class="tableLine">
					<span class="date"> <?= dateFromString("d-m-y",$cmscontentmetadata->datemodified); ?></span>
				</td> 
				 <td  colspan="1" class="tableLine">
                           <a href="/cms/html/index.php?fileNo=5000&documentCode=<? print($row->documentcode); ?>" ><?= $title ?></a>
				</td>
				<td colspan="1" class="tableLine">
							<?php 
							//get the class type
							$classDoc = $cmsDocument->openDocument($row->url);
							
							echo $classDoc->listlabel;
							
							
							
							?>
				</td>
				<td width="15%" class="tableLine">
                    <span class="date"> <?= dateFromString("d-m-y",$cmscontentmetadata->dateadded); ?></span>                        
				</td>
				
				<td width="18%" align="right" class="iconCell">
<?
				
				$activeImage = $cmscontentmetadata->isactive == '1' ? 'active' : 'inactive';
				//<img src="/cms/images/cnt_$activeImage.gif" alt="" border="0" />
				
				
	if (!approveFormAuth($authInfo, $formDescription, $cmscontentmetadata->documentcode, $db)){
		if ($cmscontentmetadata->isactive){ ?><img src="/cms/images/cnt_active.gif" alt="approved" border="0"/><? } else { ?><img src="/cms/images/cnt_inactive.gif" alt="Unapproved" border="0"/><?  }
	} else {
		if ($cmscontentmetadata->isactive){ ?>
		<a href="#" onclick="approveDocument(this); return false" rel="on" id="approve_<?= $cmscontentmetadata->documentcode ?>"><img src="/cms/images/dotGreen.gif" alt="" border="0"/></a>
		<? } else { ?>
		<a href="#" onclick="approveDocument(this); return false" rel="off" id="approve_<?= $cmscontentmetadata->documentcode ?>"><img src="/cms/images/dotRed.gif" title="Approve Content" alt="Approve Content" border="0"/></a>
		<?  
		}		
	}
				
				$editFileNo = extractNumberWithKeyFromArray( $formDescription->formid, $CMS_CUSTOM_ADD_PAGES, 2);
/*
?>
<a href="/cms/html/index.php?fileNo=5000&documentCode=<? print($row->documentcode); ?>" ><img src="/cms/images/viewIcon.gif" alt="" border="0"/></a>
<?*/


				//
				//	$returnURL = $_SERVER['REQUEST_URI'];
					

					
					if (editFormAuth($authInfo, $formDescription, $row->documentcode, $db)) { 
?>
<a href="/cms/html/index.php?fileNo=2&documentCode=<? print($row->documentcode); ?>&returnURL=<?= urlencode($returnURL) ?>" ><img src="/cms/images/editIcon.gif" alt="Edit Record" title="Edit Record" border="0"/></a> 
<?
					}
					
					if (addFormAuth($authInfo, $formDescription, $row->documentcode, $db)){
?>
<a href="/cms/html/index.php?formId=<?= $row->formid ?>&replicateDocument=YES&fileNo=2&replicatecode=<?= ($row->documentcode); ?>&returnURL=<?= urlencode($returnURL) ?>" ><img src="/cms/images/cloneIcon.gif" alt="Copy Record"  title="Copy Record" border="0"/></a> 
<?						
					}					
					
					if(deleteFormAuth($authInfo, $formDescription, $row->documentcode, $db)) {
?>
  <a href="/cms/html/index.php?fileNo=4&documentCode=<?= ($row->documentcode); ?>&returnURLEncoded=<?= urlencode($returnURL) ?>&cancelURLEncoded=<?= urlencode($cancelURL) ?>" ><img alt="Delete Record" title='Delete Record' src="/cms/images/binIcon.gif"  border="0"/></a>
<?
					}
?> 
				</td>
				
				</tr>
<?
	}

?>				
			</table>	

			
	  
